home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / utils / blankaway.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  943 b   |  53 lines

  1. #include <exec/exec.h>
  2. #include <stdio.h>
  3. void sr(char *s);
  4. char File[200];
  5. char TFile[200];
  6. main(int argc,char *argv[])
  7. {
  8.   FILE *fi,*fo;
  9.   if(argc!=2)
  10.   {
  11.      printf("\n");
  12.      printf("BlankAway version 1.0, written by Joseph Hodge\n");
  13.      printf("usage: BlankAway <filename>\n");
  14.      printf("   ie: BlankAway sys:text\n");
  15.      printf("\n");
  16.      exit(0);
  17.   }
  18.   strcpy(File,argv[1]);
  19.   sr(File);
  20.   strcpy(TFile,File);
  21.   strcat(TFile,".");
  22.   if(access(File,0))
  23.   {
  24.     printf("\nFile %s does not exist\n\n",File);
  25.     exit(0);
  26.   }
  27.   Rename(File,TFile);
  28.   fo=fopen(File,"w");
  29.   fi=fopen(TFile,"r");
  30.   while(fgets(File,180,fi)!=NULL)
  31.   {
  32.      sr(File);
  33.      if(strlen(File)!=0) fprintf(fo,"%s\n",File);
  34.   }
  35.   fclose(fi);
  36.   fclose(fo);
  37.   DeleteFile(TFile);
  38.   printf("Conversion Complete\n");
  39.  
  40.   exit(0);
  41.  
  42. }
  43.  
  44. void sr(char *s)
  45. {
  46.   register int i;
  47.   i=strlen(s)-1;
  48.   while(i>-1)
  49.   {
  50.     if(*(s+i)<=' ') *(s+i)='\0'; else break;
  51.     i--;
  52.   }
  53. }